import React from 'react';
import "./style.less";
import { redirect } from 'lib/utils';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import NavBar from 'components/NavBar';
import BeaconBar from 'components/BeaconBar';

export default class App extends React.Component {
    getBottomBarStatus(){
        let bottomBar = false;
        if(this.props.children){
            if(this.props.children.props.route && this.props.children.props.route.params){
                bottomBar = this.props.children.props.route.params.bottomBar;
            }
        }
        return bottomBar;
    }
    getBeaconBarStatus(){
        let beaconBar = false;
        if(this.props.children){
            if(this.props.children.props.route && this.props.children.props.route.params){
                beaconBar = this.props.children.props.route.params.beaconBar;
            }
        }
        return beaconBar;
    }
    render() {
       const bottomBar = this.getBottomBarStatus();
       const beaconBar = this.getBeaconBarStatus();
        return (
            <MuiThemeProvider>
                <div className="app-container">
                    <div className="view-container">
                        {
                            this.props.children
                        }
                    </div>
                    {
                        bottomBar ?
                            <NavBar active={ bottomBar - 1 } />
                            :
                            null
                    }
                    {
                        beaconBar?
                            <BeaconBar active={ beaconBar - 1 } />
                            :
                            null
                    }
                </div>
            </MuiThemeProvider>
        )
    }
}
